<template>
  <div style="background-color: white;min-height:100vh;">
    <el-header>
      <div class="header">
        <div class="app-name">
          <router-link to="/platform-admin">
          </router-link>
        </div>
        <span class="app-title">
                    <img src="@/assets/04.png" style="
                            width: 40px;
                            height: 40px;
                            margin: 5px 5px 10px 0;
                            -webkit-user-drag: none;
                            -khtml-user-drag: none;
                            -moz-user-drag: none;
                            user-drag: none;
                        "/>
                    <span style="color: black;display: inline-block;margin-top: 10px; font-size: 24px;">
                        茶韵方舆后台 <b>{{ admin.nickname }}</b>
                    </span>
                </span>
        <div class="app-logOut">
          <el-button style="margin-right: 100px" type="primary" @click="logout"> 退出账号</el-button>
        </div>
      </div>
    </el-header>
    <el-container>
      <div class="mainBody">
        <el-aside>
          <el-col :span="24">
            <el-menu  @select="handleSelect">
              <el-menu-item  index="1">
                <span slot="title"> 交易物品管理</span>
              </el-menu-item>
              <el-menu-item  index="2">
                <span slot="title"> 订单信息管理</span>
              </el-menu-item>
              <el-menu-item  index="3">
                <span slot="title"> 用户信息管理</span>
              </el-menu-item>
              <el-menu-item  index="4">
                <span slot="title"> 茶叶历史和新闻管理</span>
              </el-menu-item>
<!--              <el-submenu>-->
<!--                <template slot="title"><span>茶艺文化专栏管理</span></template>-->
<!--                <el-menu-item index="5">茶艺知多少</el-menu-item>-->
<!--                <el-menu-item index="6">茶学中心</el-menu-item>-->
<!--                <el-menu-item index="7">联系我们</el-menu-item>-->
<!--              </el-submenu>-->
              <el-menu-item  index="5">
                <span slot="title"> 茶艺文化专栏管理</span>
              </el-menu-item>
              <el-menu-item  index="6">
                <span slot="title"> 话题专栏管理</span>
              </el-menu-item>
              <el-menu-item  index="7">
                <span slot="title"> 话题讨论专栏管理</span>
              </el-menu-item>
<!--              <el-menu-item  index="6">-->
<!--                <span slot="title"> 茶文化论坛管理</span>-->
<!--              </el-menu-item>-->
<!--              <el-menu-item  index="7">-->
<!--                <span slot="title"> 采摘资讯管理</span>-->
<!--              </el-menu-item>-->
            </el-menu>
          </el-col>
        </el-aside>
        <el-main>
          <teaGoods v-if="mode == 1"></teaGoods>
          <orderList v-if="mode == 2"></orderList>
          <userList v-if="mode == 3"></userList>
          <articleList v-if="mode == 4"></articleList>
          <teaScience v-if="mode == 5"></teaScience>
          <topic v-if="mode == 6"></topic>
          <discuss v-if="mode == 7"></discuss>
<!--          <userList v-if="mode == 6"></userList>-->
<!--          <userList v-if="mode == 7"></userList>-->
        </el-main>
      </div>
    </el-container>
  </div>
</template>

<script>
import teaGoods from '../common/teaGoods.vue'
import orderList from '../common/orderList.vue'
import userList from '../common/userList.vue'
import articleList from '../common/articleList.vue'
import teaScience from '../common/teaScience.vue'
import topic from "@/components/common/topic.vue";
import discuss from "@/components/common/discuss.vue";

export default {
  name: "platform-admin",
  components: {
    teaGoods,
    orderList,
    userList,
    articleList,
    teaScience,
    topic,
    discuss
  },
  data() {
    return {
      mode: 1,
      admin: {
        nickname: '管理员',
      },
    }
  },
  created() {
    this.admin.nickname = this.$sta.adminName;
  },
  methods: {
    logout() {
      this.$api.loginOut({}).then(res => {
        if (res.status_code === 1) {
          this.$sta.isLogin = false;
          this.$sta.adminName = '';
          this.$router.push({path: '/login-admin'});
        }
      }).catch(e => {
        console.log(e)
      })
    },
    handleSelect(val) {
      if (this.mode !== val) {
        this.mode = val
      }
    },
  },
}
</script>

<style scoped>
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-width: 100vw;
  height: 58px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: lightgrey solid 2px;
  z-index: 1000;
}

.app-name {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 11vw;
  flex: 1;
  height: 100%;
  border-right: 1px solid #fff;
  background-color: white;

}

.app-name a {
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  padding: 10px 20px 0 0;
}

.app-title {
  display: flex;
  justify-content: center;
  flex: 8;
  color: black;
  font-size: 28px;
}

.app-logOut {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  align-items: center;
}

.mainBody {
  display: flex;
  width: 100%;
}

aside {
  /* flex: 1; */
  box-sizing: content-box;
  min-height: calc(100vh - 100px);
  background-color: rgb(255, 255, 255);
  border-top: 1px solid lightgrey;
  border-right: 1px solid lightgrey;
}

main {
  flex: 9;
}

.foot {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 58px;
  background-color: #ffffff;
}
</style>